package sg.edu.nus.iss.vmcs.customer;

import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.Panel;
import java.awt.event.ActionListener;

import sg.edu.nus.iss.vmcs.util.WarningDisplay;


public class DrinkSelectionItem extends Panel {
	
	private Button btn;
	private Label lblPrice;
	private WarningDisplay lblItemState;	
	
	private final String NOT_IN_STOCK="Not in Stock";
	
	public DrinkSelectionItem(){
		
		btn=new Button();
		btn.setBackground(Color.white);
		
		lblPrice=new Label();
		Panel pnlPrice=new Panel(new FlowLayout(FlowLayout.CENTER));
		pnlPrice.add(lblPrice);
		
		lblItemState=new WarningDisplay(NOT_IN_STOCK);
		Panel pnlItemState=new Panel(new FlowLayout(FlowLayout.CENTER));
		pnlItemState.add(lblItemState);
		
		this.setLayout(new GridLayout(0,3));
		this.add(btn);
		this.add(pnlPrice);
		this.add(pnlItemState);			
		
	}
	
	public void addListener(ActionListener l) {
		btn.addActionListener(l);		
	}
	
	//Extra Method
	public void setActionCommand(String idx){
		btn.setActionCommand(idx);
	}
	
	public void setName(String name) {		
		btn.setLabel(name);
	}


	/*public void setPrice(String price) {		
		lblPrice.setText(price);
	}*/

	public void setPrice (int price){
		lblPrice.setText(price + " C");
	}
	
	public void setItemState(Boolean active) {
		btn.setEnabled(active);		
		lblItemState.setState(!active);
	}

}
